package com.cljz.makepassenger.ui.holder;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cljz.makepassenger.base.App;
import com.cljz.makepassenger.R;
import com.cljz.makepassenger.model.net.bean.ActivityMyBean;
import com.squareup.picasso.Picasso;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;


/**
 * Created by apple on 2017/5/2.
 */

public class MineActivityHolder extends RecyclerView.ViewHolder {
    @BindView(R.id.iv_from)
    ImageView ivFrom;
    @BindView(R.id.tv_invite_title)
    TextView tvInviteTitle;
    @BindView(R.id.civ_head)
    CircleImageView civHead;
    @BindView(R.id.tv_invite_time)
    TextView tvInviteTime;
    @BindView(R.id.tv_invite_place)
    TextView tvInvitePlace;
    @BindView(R.id.tv_invite_member)
    TextView tvInviteMember;
    @BindView(R.id.ll_invite_describe)
    LinearLayout llInviteDescribe;
    @BindView(R.id.frontView)
    LinearLayout frontView;
    @BindView(R.id.iv_activity_tag)
    ImageView ivActivityTag;

    public MineActivityHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);
    }

    public void setData(List<ActivityMyBean.DataBean> activityMyList, int position) {
        ActivityMyBean.DataBean data = activityMyList.get(position);
        tvInviteMember.setText(data.getNumber_join() + "人");
        tvInvitePlace.setText(data.getAddress());
        tvInviteTime.setText(data.getDate() + " " + data.getWeek() + " " + data.getTime());
        tvInviteTitle.setText(data.getTitle());
        Picasso.with(App.getInstance()).load(data.getUser_logo()).placeholder(R.mipmap.head_loading).error(R.mipmap.head_loading).into(civHead);
        if ("0".equals(data.getIs_expire())) {
            ivFrom.setImageResource(R.mipmap.biaoqian_guoqi);
            ivActivityTag.setVisibility(View.GONE);
        } else {
            if ("1".equals(data.getIs_invite())) {
                ivFrom.setImageResource(R.mipmap.biaoqian_yaoqing);
            } else {
                ivFrom.setImageResource(R.mipmap.biaoqian_shouyao);
            }
            if ("1".equals(data.getIs_expire())) {
                ivActivityTag.setVisibility(View.VISIBLE);
                ivActivityTag.setImageResource(R.mipmap.myac_ing);
            } else if ("2".equals(data.getIs_expire())) {
                ivActivityTag.setVisibility(View.VISIBLE);
                ivActivityTag.setImageResource(R.mipmap.myac_end);
            }
        }
    }
}
